<HTML>
<HEAD>
<TITLE>SHIPS</TITLE>
</HEAD>

<center>
<H1>CEOI 96 Day 1 Problem 2</h1>
<h1>Ships</H1>
</center>

<P>The Palmia country is divided by a river into the north and south bank.
There are N towns on both the north and south bank. Each town on the north
bank has its unique friend town on the south bank. No two towns have the
same friend. </P>

<P>Each pair of friend towns would like to have a ship line connecting
them. They applied for permission to the government. Because it is often
foggy on the river the government decided to prohibit intersection of ship
lines (if two lines intersect there is a high probability of ship crash).
</P>

<P>Your task is to write a program to help government officials decide
to which ship lines they should grant permission to get maximum number
of non intersecting ship lines. </P>

<H2>Input</H2>

<P>The input file consists of several blocks. In the first line of each
there are 2 integers X,Y separated with exactly one space, X represents
the length of the Palmia river bank (10 &lt;= X &lt;= 6000), Y represents
the width of the river (10 &lt;= Y &lt;= 100). The second line contains
the integer N, the number of towns situated on both south and north riverbanks
(1 &lt;= N &lt;= 5000). On each of the next N lines there are two non-negative
integers C,D separated with space (C,D &lt;= X), representing distances
of the pair of friend towns from the western border of Palmia measured
along the riverbanks (C for the town on the north bank, D for the town
on the south bank). There are no two towns on the same position on the
same riverbank. After the last block there is a single line with two numbers
0 separated by a space. </P>

<H2>Output</H2>

<P>For each block of the input file the output file has to contain in consecutive
lines the maximum possible number of ship lines satisfying the conditions
above. </P>

<H2>Sample Input</H2>
<PRE>
30 4
7
22 4
2 6
10 3
15 12
9 8
17 17
4 2
0 0
</pre>

<h2>Sample Output</h2>
<PRE>
4
</PRE>
</BODY>
</HTML>
